package com.agile.leetcode.rmi.server;

import com.agile.leetcode.rmi.service.IService;
import com.agile.leetcode.rmi.service.impl.ServiceImpl;

import javax.naming.Context;
import javax.naming.InitialContext;
import java.rmi.registry.LocateRegistry;
import java.rmi.registry.Registry;

/**
 * @Author:ChenZhangKun
 * @Date: 2021/12/27 22:44
 */
public class Server {
    public static void main(String[] args) {
        try {
            LocateRegistry.createRegistry(1099);
            IService service = new ServiceImpl("service");
            Context namingContext = new InitialContext();
            namingContext.rebind("rmi://127.0.0.1/service", service);
        } catch (Exception e) {
            e.printStackTrace();
        }

    }
}
